#!/bin/bash

# 等待数据库服务启动
echo "等待数据库连接..."
while ! mysqladmin ping -h"db" -u"mysql" -p"enghou123" --silent; do
    sleep 1
done
echo "数据库连接成功！"

# 安装Composer依赖
echo "安装Composer依赖..."
composer install --no-dev --optimize-autoloader

# 执行数据库迁移
echo "执行数据库迁移..."
php think migrate:run

echo "初始化完成，启动Apache..."
# 启动Apache
exec apache2-foreground